home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 009a / snpd0493.zip / MEMAVAIL.C < prev    next >
C/C++ Source or Header  |  1993-04-05  |  511b  |  33 lines

  1. /*
  2. **  MEMAVAIL.C - Report available DOS memory
  3. **
  4. **  public domain by Thor Johnson
  5. */
  6.  
  7. #include <dos.h>
  8.  
  9. long memavail(void)
  10. {
  11.       union REGS regs;
  12.  
  13.       /* Request impossibly large number of 16-byte paragraphs from DOS */
  14.  
  15.       regs.h.ah = 0x48;
  16.       regs.x.bx = 0xFFFF;
  17.  
  18.       int86(0x21,®s,®s);
  19.  
  20.       return((long)regs.x.bx * 16L);
  21. }
  22.  
  23. #ifdef TEST
  24.  
  25. #include <stdio.h>
  26.  
  27. main()
  28. {
  29.       printf("Available DOS memory = %ld bytes\n", memavail());
  30. }
  31.  
  32. #endif /* TEST */
  33.